package com.lingchen.boot.utils;

import com.google.common.base.Splitter;

import java.util.Map;

/**
 * url and html utils.
 *
 * @author code4crafter@gmail.com <br>
 * @since 0.1.0
 */
public class UrlUtils {

    /**
     * 仅获取?后的指定参数
     */
    public static String getParam(String url, String name) {
        Map<String, String> params = getAllParam(url);
        return params.get(name);
    }

    /**
     * 仅获取?后的全部参数
     */
    public static Map<String, String> getAllParam(String url) {
        String params = url.substring(url.indexOf("?") + 1, url.length());
        return Splitter.on("&").withKeyValueSeparator("=").split(params);
    }

}
